

import UIKit
/*
如果你暂时还没有分析出来需要抽取的功能或者属性,那就把这里所有的代码都删除掉,只保留控制器的生命周期方法
*/
class YYBaseTableViewController: UITableViewController,YYVisitorViewDelegate {

    let isLogin: Bool = false

    //定义一个属性来接受访客视图
    var visitorView: YYVisitorView?

    override func loadView() {
        if isLogin{
            super.loadView()
        }else{
            visitorView = YYVisitorView()

            //报错要去遵守代理协议
            visitorView?.delegate = self



            view = visitorView


            //设置 NAV
            setupNav()
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }


    private func setupNav(){


        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "didRegisterMethod")



        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "didLoginMethod")
    }
}

 // MARK: - visitorViewdelegate
    //只是用于代码分离
extension YYBaseTableViewController{


   
    func didRegisterMethod() {

    }


    func didLoginMethod() {

        let oauth = YYOAuthViewController()

        let nav = UINavigationController(rootViewController: oauth)

        presentViewController(nav, animated: true ) { () -> Void in

        }
    }
}

//我们不能扩展自定义的属性
extension YYBaseTableViewController{

}